home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / Rexx / ImageDimensions.ced < prev    next >
Text File  |  1998-06-21  |  2KB  |  70 lines

  1. /**
  2.  **  ImageDimensions.CEd V1.0 (31-Aug-97) For CygnusEd & Visage
  3.  **
  4.  **  This script will paste the width and height for the image
  5.  **  specified within an <IMG> tag.
  6.  **  Bind it to a hotkey, and press that key while
  7.  **  the cursor is placed inside an <Img Src=...> tag.
  8.  **  This doesn't work for pictures given an absolute path,
  9.  **  like http://... but you probably knew that ;^)
  10.  **
  11.  **
  12.  **  For feedback write Allan Odgaard <Duff@DIKU.DK>
  13.  **/
  14.  
  15. /* Please customize this line */
  16. Visage = "Duff's:Graphics/Visage"
  17.  
  18. /* The rest should work without your interference :-) */
  19. Options Results
  20.  
  21. Status DirName;       Path    = RESULT
  22. Status CursorColumn;  CursorX = RESULT
  23. Status LineBuffer;    Line    = RESULT
  24. Status CursorLine;    LineNr  = RESULT
  25.  
  26. EndTag    = Right(Line, Length(Line)-CursorX)
  27. EndTagPos = Pos(">", EndTag)
  28.  
  29. If(EndTagPos > 0) Then
  30. Do
  31.     Line = Upper(Left(Line, EndTagPos+CursorX))
  32.     StartTagPos = Pos("GMI<", Reverse(Line))
  33.     If(StartTagPos > 0) Then
  34.     Do
  35.         Tag        = Right(Line, StartTagPos+3)
  36.         PicturePos = Pos("SRC=", Tag)
  37.         If(PicturePos > 0) Then
  38.         Do
  39.             Name = Right(Tag, Length(Tag)-PicturePos-3)
  40.  
  41.             If(Left(Name, 1) = '"') Then
  42.                 Parse Var Name '"' FileName '"' rest
  43.             Else
  44.             Do
  45.                 Parse Var Name FileName '>' rest
  46.                 Parse Var FileName FileName ' ' rest
  47.             End
  48.  
  49.             If(Right(Path, 1) = ':') Then
  50.                     File = Path || FileName
  51.             Else    File = Path || '/' || FileName
  52.  
  53.             Address Command Visage '>T:ImgDimensions "'File'" Info'
  54.             If(RC = 0) Then
  55.             Do
  56.                 Open('Size','T:ImgDimensions','Read')
  57.                 Info = ReadLn('Size')
  58.                 Info = ReadLn('Size')
  59.                 Info = Right(Info, Length(Info)-10)
  60.                 Close('Size')
  61.  
  62.                 Parse Var Info width 'x' height 'x' rest
  63.  
  64.                 JumpTo LineNr+1 Length(Line)-StartTagPos+2
  65.                 Text " Width=" || width || " Height=" || height
  66.             End
  67.         End
  68.     End
  69. End
  70.